package com.example.xiaomi.Model.Service;

import com.example.xiaomi.Model.Controller.orderList;
import com.example.xiaomi.Model.Controller.shoppingcartList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/settlement")
public class settlement extends HttpServlet {
   shoppingcartList shoppingcartList = new shoppingcartList();
   orderList orderList = new orderList();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String totalcost = req.getParameter("totalcost");
        String id = req.getParameter("id");
        String data = req.getParameter("cid");
        String data2 = req.getParameter("number");
        String[] cid = data.split(",");
        String[] number = data2.split(",");

        for (int i = 1; i < cid.length; i++) {
            int conid = Integer.parseInt(cid[i]);
            int uid = Integer.parseInt(id);
            shoppingcartList.doDelete(uid,conid);
        }
        System.out.println(id);
        System.out.println(data);
        System.out.println(data2);
        //orderList.doInsert(id,data,data2)
        req.getRequestDispatcher("/WEB-INF/Xiaomi/settlement.jsp").forward(req,resp);
    }
}
